package com.jxsm.service.impl.export;

import com.jxsm.dao.export.ExportproductDao;
import com.jxsm.page.Page;
import com.jxsm.pojo.Exportproduct;
import com.jxsm.service.export.ExportProductService;
import com.jxsm.util.UtilFuns;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/11/11.
 */
@Service
public class ExportProductServiceimpl implements ExportProductService {
    @Autowired
    private ExportproductDao exportproductDao;
    public void insert(Exportproduct entity) {
        exportproductDao.insert(entity);
    }

    public void update(Exportproduct entity) {
        exportproductDao.update(entity);
    }

    public void deleteById(Serializable id) {
        exportproductDao.deleteById(id);
    }

    public void delete(Serializable[] id) {
        exportproductDao.delete(id);
    }

    public List<Exportproduct> findPage(Page page) {
        return exportproductDao.findPage(page);
    }

    public List<Exportproduct> find(Map map) {
        return exportproductDao.findAll(map);
    }

    public Exportproduct get(Serializable id) {
        return exportproductDao.get(id);
    }

    public String exportproducts(String exportId) {
        Map map=new HashMap();
        map.put("exportId",exportId);
        List<Exportproduct> exportproducts=exportproductDao.findAll(map);
        StringBuffer stringBuffer=new StringBuffer();
        for(Exportproduct exportproduct:exportproducts){
            stringBuffer.append("addTRRecord(\"mRecordTable\", \"").append(exportproduct.getId()).append("\", \"").append(exportproduct.getProductNo()).append("\", \"").append(exportproduct.getCnumber()).append("\", \"").append(UtilFuns.convertNull(exportproduct.getGrossWeight())).append("\", \"").append(UtilFuns.convertNull(exportproduct.getNetWeight())).append("\", \"").append(UtilFuns.convertNull(exportproduct.getSizeLength())).append("\", \"").append(UtilFuns.convertNull(exportproduct.getSizeWidth())).append("\", \"").append(UtilFuns.convertNull(exportproduct.getSizeHeight())).append("\", \"").append(UtilFuns.convertNull(exportproduct.getExPrice())).append("\", \"").append(UtilFuns.convertNull(exportproduct.getTax())).append("\");");

        }
        return stringBuffer.toString();
    }
}
